import axios from './axios'
import qs from 'qs'
import {baseUrl} from '@/config/config'
var preUrl = baseUrl + '/dorm/api/app/group'
export const addGroup = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl,
            method: 'post',
            data
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const getGroupList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl,
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const deleteGroup = (id) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/' + id,
            method: 'delete'
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const updateGroup = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/' + data.id,
            method: 'put',
            data
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const getGroup = (id) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/' + id,
            method: 'get'
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const studentGroupAdd = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/studentGroupAdd',
            method: 'post',
            data
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const studentGroupRemove = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/studentGroupRemove',
            method: 'post',
            data
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const studentGroup = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: preUrl + '/studentGroup',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}
